﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AgentRegistion.aspx.cs" Inherits="Yule8xWechat.Payment.WxPay.AgentRegistion" %>

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>注册代理</title>
    <link rel="stylesheet" type="text/css" href="/Skin/Theme/Css/comm.css" />
    <link rel="stylesheet" type="text/css" href="/Skin/Theme/Css/icon.css" />
    <link rel="stylesheet" type="text/css" href="/Skin/Theme/Css/my.css" />
    <link rel="stylesheet" type="text/css" href="/Skin/Theme/Css/agent.css" />
    <script src="/Skin/Theme/Js/flexible_css.js" type="text/javascript" charset="utf-8"></script>
    <script src="/Skin/Theme/Js/flexible.js" type="text/javascript" charset="utf-8"></script>
    <script src="/Skin/Theme/Js/jquery_2.1.3.js" type="text/javascript" charset="utf-8"></script>
    <script src="/Skin/Plugins/DialogLib/layer-v3.0.1/layer.js" type="text/javascript"></script>
</head>
<body>
    <div class="content b-h">
        <!--注册代理事项-->
        <div class="regagenttip">
            <div class="tiptext">
                <a class="t-r">注册需知</a><p>购买<a class="t-r">100颗钻石</a>即成为代理，<a class="t-r">1颗钻石=3元</a></p>
                <p>注册成功后<a class="t-r">立即返利75元</a>至账户</p>
                <p>每发展1个1级代理即可<a class="t-r">获25%返佣</a>，2级代理<a class="t-r">获15%返佣</a></p>
            </div>
        </div>
        <!--代理基础信息-->
        <form method="post" action="AgentRegistion.aspx?user_id=<%=user_id %>" onsubmit="return validateform()">
            <div class="baseinfo">
                <ul>
                    <li>
                        <div class="basetext">
                            <span class="anameicon">
                                <img src="/Skin/Theme/Images/agent/agentname.png"></span><span class="anametext">推荐人ID</span><span class="anameinput"><input type="text" name="parent1_uid" placeholder="请输入推荐人ID" value="<%=wxUser.parent1_uid<1?string.Empty:wxUser.parent1_uid.ToString() %>" data-uid="<%=wxUser.user_id %>" /></span>
                        </div>
                    </li>
                    <li>
                        <div class="basetext">
                            <span class="anameicon">
                                <img src="/Skin/Theme/Images/agent/agentname.png"></span><span class="anametext">代理名称</span><span class="anameinput"><input type="text" name="realname" placeholder="请输入您的名字" required="required" /></span>
                        </div>
                    </li>
                    <li>
                        <div class="basetext">
                            <span class="anameicon">
                                <img src="/Skin/Theme/Images/agent/agentphone.png"></span><span class="anametext">手机号码</span><span class="anameinput"><input type="text" name="mobile" placeholder="请输入您的手机号" required="required" /></span>
                        </div>
                    </li>
                    <li>
                        <div class="basetext">
                            <span class="anameicon">
                                <img src="/Skin/Theme/Images/agent/code.png"></span><span class="anametext">验	证	码</span><span class="acodeinput"><input type="text" name="yzm" placeholder="请输入验证码" required="required" /></span><span class="agetcode"><a id="btn-get-sms-code" href="../../PublicServices/SMSServices.aspx?uid=<%=wxUser.user_id %>"  data-sec="<%=smscountdown %>">获取验证码</a></span>
                        </div>
                    </li>
                </ul>
            </div>
            <!--代理区域信息-->
            <div class="baseinfo">
                <ul>
                    <li><div class="basetext"><span class="anametext"><a class="t-r">手机号将作为提现时唯一认定标准，请认真填写</a></span></div></li>	

                    <li>
                        <div class="basetext">
                            <span class="anameicon">
                                <input type="checkbox" required="required" id="agreelicense"></span><span class="anametext"><a href="#">同意代理协议条款</a></span>
                        </div>
                    </li>
                </ul>
            </div>
            <!--代理区域信息-->
            <div class="regbutton">
                <span class="regbtn fanbai">
                    <button type="submit" disabled="disabled">抢先成为代理</button></span>
            </div>
            <input type="hidden" name="action" value="submit" />
        </form>
    </div>
    <script src="/Skin/Theme/Js/jquery-1.10.1.min.js"></script>
    <script>
        function validateform() {
            var pid=$('input[name="parent1_uid"]').val();
            if (pid.length < 1) {
                layer.msg('推荐人ID不能为空，详情请咨询客服!');
                return false;
            } else {
                if (pid == $('input[name="parent1_uid"]').data('uid')) {
                    layer.msg('推荐人不能是自己!');
                    return false;
                }
            }
            if ($('input[name="realname"]').val().length < 1) {
                layer.msg('姓名不能为空!');
                return false;
            }
            if ($('input[name="mobile"]').val().length < 1) {
                layer.msg('手机号码不能为空!');
                return false;
            }
            return true;
        }
        $('#agreelicense').click(function () {
            var checked = $(this).prop('checked');
            if (checked) {
                $(':submit').prop('disabled', false).parent().removeClass('fanbai');
            } else {
                $(':submit').prop('disabled', true).parent().addClass('fanbai');
            }
        })
        //initAreaPicker();
        /**
         * 初始化省市区
         * @returns {undefined}
         * @since 1.0 2017-4-12 SoChishun Added.
         */
        function initAreaPicker() {
            //$('.xsui-area-picker').regionPicker();
            var $areapicker = $('.xsui-area-picker');
            $.get($areapicker.data('provinceUrl'), function (data) {
                if ('string' == typeof (data)) {
                    data = $.parseJSON(data);
                }
                var str = '<option value="">==选择省份==</option>';
                for (var i in data) {
                    str += '<option value="' + data[i].name + '" data-id="' + data[i].pid + '">' + data[i].name + '</option>';
                }
                $areapicker.find('[name="province"]').html(str);
            })
            $areapicker.find('[name="province"]').change(function () {
                var url = $areapicker.data('cityUrl').replace('varpid', $(this).find(':selected').data('id'));
                $.get(url, function (data) {
                    if ('string' == typeof (data)) {
                        data = $.parseJSON(data);
                    }
                    var str = '<option value="">==选择城市==</option>';
                    for (var i in data) {
                        str += '<option value="' + data[i].name + '" data-id="' + data[i].cid + '">' + data[i].name + '</option>';
                    }
                    $areapicker.find('[name="city"]').html(str);
                });
            });
            $areapicker.find('[name="city"]').change(function () {
                var url = $areapicker.data('areaUrl').replace('varcid', $(this).find(':selected').data('id')).replace('varpid', $areapicker.find('[name="province"]').find(':selected').data('id'));
                console.log(url);
                $.get(url, function (data) {
                    if ('string' == typeof (data)) {
                        data = $.parseJSON(data);
                    }
                    var str = '<option value="">==选择地区==</option>';
                    for (var i in data) {
                        str += '<option value="' + data[i].name + '" data-id="' + data[i].aid + '">' + data[i].name + '</option>';
                    }
                    $areapicker.find('[name="area"]').html(str);
                });
            });
        }
        $('#btn-get-sms-code').click(function () {
            var $this = $(this);
            if ($this.parent().hasClass('fanbai')) {
                return false;
            }
            var mobile = $('[name="mobile"]').val();
            if (mobile.length < 1) {
                layer.msg('手机号码未填写!');
                return false;
            }
            $('#btn-get-sms-code').data('reset', false);
            var url = $this.attr('href');
            $.get(url, { "type": "agentregistconfirm", "mobile": mobile }, function (data) {
                layer.msg(data);
                if (data.indexOf('成功') < 0) {
                    $('#btn-get-sms-code').data('reset', true);
                }
            })
            $this.parent().addClass('fanbai');
            button_countdown();
            return false;
        })
        // 按钮倒计时功能
        function button_countdown() {
            var sec = $('#btn-get-sms-code').data('sec');
            if (!sec) {
                sec = 60;
            }
            var text = $('#btn-get-sms-code').text();
            var intv = setInterval(btn_countdown_fnc, 1000);
            var reset;
            function btn_countdown_fnc() {
                reset = $('#btn-get-sms-code').data('reset');
                sec--;
                if (sec < 1 || reset) {
                    clearInterval(intv);
                    $('#btn-get-sms-code').text(text).parent().removeClass('fanbai');
                    return;
                }
                $('#btn-get-sms-code').text(text + '(' + sec + ')');
            }
        }
    </script>
</body>
</html>
